import React from 'react'
import {connect} from 'dva-no-router'
import {bindActionCreators} from 'redux'

import UI from '../components/tasksList';

class App extends React.Component {
  componentWillMount(){
      const {queryTasks}=this.props;
      queryTasks();
  }
  componentWillUnmount(){
      const {getClean}=this.props;
      getClean();
  }
  render() {
    return (
      <UI {...this.props}/>
    )
  }
}

const actions = {
  query: (val) => ({type: 'taskReceive/query', payload: val}),
  getTaskId: (id) => ({type: 'taskReceive/getTaskId', payload: id}),
  cleanData: () => ({type: 'tasksList/cleanData'}),
  queryTasks: () => ({type: 'tasksList/queryTasks'}),
  getClean:() => ({type: 'tasksList/getClean'}),
    thisTextChange: (val) => ({type: 'tasksList/thisTextChange',payload:val}),
    search: () => ({type: 'tasksList/search'}),
    selectRowData: (val) => ({type: 'tasksList/selectRowData',payload:val}),
};

const mapProps = ({tasksList}) => ({...tasksList});

const mapActions = dispatch => ({
  ...bindActionCreators({...actions}, dispatch)
});

export default connect(mapProps, mapActions)(App)